import Xhr, { Methods, IResponse } from 'src/models/http'

type methodType = (
    prefix: (url: string) => string,
    method: Methods,
    url: string,
    params?: any
) => Promise<IResponse>

/**
 * 创建通用的请求函数
 * @date 2021-07-06
 * @param {Method} method
 * @param {string} url
 * @returns {IResponse}
 */
export const createRequestMethod: methodType = async (prefix, method, url, params) => {
    return await Xhr({ url: prefix(url), method, params })
}
